#include<bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;
int n,a[N];

int has[N];
namespace Sol1{
    bool C[N];
    int ans = 0;
    void dfs(int i){
        if(i >= n){
            int cnt = 0;
            int lst = -1;
            for(int i = 1;i <= n;i++){
                if(C[i]){
                    if(lst == -1){
                        lst = i;
                    }
                    else{
                        if(a[i] == a[lst]){
                            cnt += a[i];
                        }
                        lst = i;
                    }
                }
            }
            lst = -1;
            for(int i = 1;i <= n;i++){
                if(!C[i]){
                    if(lst == -1){
                        lst = i;
                    }
                    else{
                        if(a[i] == a[lst]){
                            cnt += a[i];
                        }
                        lst = i;
                    }
                }
            }
            ans = max(ans,cnt);
            return;
        }
        C[i] = 0;
        dfs(i + 1);
        C[i] = 1;
        dfs(i + 1);
        return;
    }
}

int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);

    int T;scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        for(int i = 1;i <= n;i++){
            scanf("%d",&a[i]);
            has[a[i]]++;
        }

        Sol1::dfs(1);
        printf("%d\n",Sol1::ans);
        Sol1::ans = 0;
    }
    return 0;
}